﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace QL_Nha_Sach_Phuong_Nam
{
    class CXulythongtinsach
    {
        private CDuLieu data;
        private CXulyNhaxuatban xulynxb=new CXulyNhaxuatban();

        public CXulythongtinsach()
        {
            data = CDuLieu.khoitao();
        }

        #region các hàm xử lý
        
        //tim theo ten sach 
        public List<Sach> TimSachtheoten(string tensach)
        {
            List<Sach> dssach = new List<Sach>();
            foreach (Sach sach in getdsSach())
            {
                if (sach.SachName.Contains(tensach))
                    dssach.Add(sach);
            }
            return dssach;
        }

        //tim theo ma sach
        public Sach TimSachtheoma(string ma)
        {
            Sach s = new Sach();
            foreach (Sach sach in getdsSach())
            {
                if (sach.SachNo == ma)
                    s = sach;
            }
            return s;
        }

        //tim sach theo id
        public Sach TimSachID(int ma)
        {
            Sach s = new Sach();
            foreach (Sach sach in getdsSach())
            {
                if (sach.SachID == ma)
                    s = sach;
            }
            return s;
        }

        //them sach
        public void ThemSach(Sach sach)
        {
            data.ThemSach(sach);
        }

        //xoa sach
        public void XoaSach(string ma)
        {
            data.XoaSach(ma);
        }
    

        //sua sach
        public void SuaSach(Sach sach, string tennxb)
        {
            data.SuaSach(sach, tennxb);
        }

        //get danh sach 
        public List<Sach> getdsSach()
        {
            return data.getdsSach();
        }

        
        #endregion
    }
}
